package com.neusoft.demo.controller;

import com.neusoft.demo.pojo.Cart;
import com.neusoft.demo.pojo.Foods;
import com.neusoft.demo.server.CartServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@CrossOrigin
@Controller
@RequestMapping("cart")
public class CartController {
    @Autowired
    CartServer cartServer;
    @ResponseBody
    @RequestMapping("list")
    public java.util.List<Cart> cartList(){
        return  cartServer.cartList();
    }
    @ResponseBody
    @RequestMapping("add")
    public boolean addCart(Cart cart){
        System.out.println(cart);
        return  cartServer.addList(cart);
    }
    @ResponseBody
    @RequestMapping("/update")
    public boolean updateCart(Cart cart){
        return cartServer.updateCart(cart);
    }
    @ResponseBody
    @RequestMapping("/del")
    public  boolean delCart(int foodId){

        return cartServer.delCart(foodId);
    }
    @ResponseBody
    @RequestMapping("/delS")
    public  boolean del(Cart cart){

        return cartServer.del(cart);
    }
}
